import React from 'react';
// import ReactDOM from 'react-dom';
import { Menu, Layout} from 'element-react';
import 'element-theme-default';
import {BrowserRouter as Router,Switch,Route,Link} from "react-router-dom";
import Cargos from './cargoManage/list';
import AddCargo from './cargoManage/addCargo';
import Edit from './cargoManage/editCargo';

class MenuList extends React.Component{
    constructor(){
        super();
        this.state={row:{} };
        
        this.getRow = this.getRow.bind(this);
    }

    //获取行
    getRow(row){
      this.setState({
        row: row
      });
    }

    render(){
        return (
        <Router>
              <el-container style={{border: '1px solid #red'}}>
                
                <Layout.Row className="tac" >
                  <Layout.Col span={4}>
                    <Menu defaultActive="1" className="el-menu-vertical-demo" theme="dark">
                      <Menu.SubMenu index="1" title={<span><i className="el-icon-menu"></i>货物信息</span>}>
                          <Link to="/toCargos">
                            <Menu.Item index="1-1"><i className="el-icon-message"></i>查询</Menu.Item>
                          </Link>
                          <Link to="/toAdd">
                            <Menu.Item index="1-2"><i className="el-icon-message"></i>新增</Menu.Item>
                          </Link>
                      </Menu.SubMenu>
                    </Menu>
                  </Layout.Col>

                  <Layout.Col span={20}>
                    <Switch >
                      <Route path="/toCargos"><Cargos fun={this.getRow}/></Route>
                      <Route path="/toAdd"><AddCargo/></Route>
                      <Route path="/toEdit" ><Edit row={this.state.row}/></Route>
                    </Switch>
                  </Layout.Col>
                </Layout.Row>
                
                
              </el-container>

        </Router>
        );
    }

}


export default MenuList;